package com.corticon.dialogs.dao.hibernate;

import org.springframework.stereotype.Repository;

import com.corticon.dialogs.dao.QuestionInSetDAO;
import com.corticon.dialogs.model.QuestionInSet;
import com.corticon.dialogs.model.QuestionSet;

@Repository("questionInSetDAO")
public class QuestionInSetHibernateDAO extends GenericHibernateDAO<QuestionInSet, Long> implements
    QuestionInSetDAO {

    @Override
    public Double getMaxSequenceByQuestionSet(QuestionSet questionSet) {
        return (Double) getSession().createQuery(
            "select max(qis.priority) from QuestionInSet qis where qis.questionSet = :qs").
            setParameter("qs", questionSet).uniqueResult();
    }
}